package com.example.myapplication2;

import android.view.View;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;


public class SharedVariablesActivity extends AppCompatActivity implements View.OnClickListener {

    private MainActivity instance;
    private EditText textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shared_variables);
        findViewById(R.id.saveDate).setOnClickListener(this);
        textView = findViewById(R.id.results2);
        reload();
    }

    private void reload() {
        instance = MainActivity.getInstance();
        String date = instance.map.get("date");
        if (date!=null){
            textView.setText(date);
        }

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.saveDate:
                instance.map.put("date",textView.getText().toString());
                break;
        }
    }
}